package com.dmw.controller;

import com.dmw.dto.Dto;
import com.dmw.service.DmSchedulerService;
import com.dmw.util.DtoUtil;
import com.dmw.vo.chooseSeatVO.ChooseSeatOfCinemaIdVO;
import com.dmw.vo.chooseSeatVO.QuerySeatInfoOfScheduleIdVO;
import com.dmw.vo.homePageVO.DefaultTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class ScheduleProviderController {

    @Autowired
    private DmSchedulerService service;

    /**
     * 选座页API 2-1 根据剧场Id查询剧场原始座位
     * @return
     */
    @PostMapping("/queryOriginalCinemaSeatArray")
    public Dto queryOriginalCinemaSeatArray(@RequestBody Map<String, Object> map){

        System.out.println(map.get("scheduleId"));
        System.out.println(map.get("cinemaId"));

        List<String> list = null;
        ChooseSeatOfCinemaIdVO vo=new ChooseSeatOfCinemaIdVO();
        try {
            list = service.queryOriginalCinemaSeatArray(map);
                vo.setCinemaId((Integer) map.get("cinemaId"));
                vo.setSeatArray(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return DtoUtil.returnDataSuccess(vo);
    }

    /**
     * 选座页API 2-2  根据排期获取剧场座位信息
     * @return
     */
    @PostMapping("/queryCinemaSeatArrayByScheduleId")
    public Dto queryCinemaSeatArrayByScheduleId(@RequestBody Map<String, Object> map){

        System.out.println(map.get("scheduleId"));
        System.out.println(map.get("cinemaId"));

        List<QuerySeatInfoOfScheduleIdVO> list = null;
        try {
            list = service.queryCinemaSeatArrayByScheduleId(map);
            System.out.println(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return DtoUtil.returnDataSuccess(list.get(0));
    }
}
